type StoreType = {
  mapView: any;
  sceneView: any;
  constraint: any;
  spatialReference: any;
  gridmanLayer: any;
  zlxmLayer: any;
  zlqyLayer: any;
  jjjgLayer: any;
  wgfwLayer: any;
  wgfwLastLayer: any;
  wgfwLabelLayer: any;
  floorLayer: any;
  gridmanLayerVisible: any;
  zlxmLayerVisible: any;
  zlqyLayerVisible: any;
  jjjgLayerVisible: any;
  wgfwLayerVisible: any;
  data: any;
};

const store: StoreType = {
  mapView: null,
  sceneView: null,
  constraint: null,
  spatialReference: { wkid: 4490 },
  gridmanLayer: null,
  zlxmLayer: null,
  zlqyLayer: null,
  jjjgLayer: null,
  wgfwLayer: null,
  wgfwLastLayer: null,
  wgfwLabelLayer: null,
  floorLayer: null,
  gridmanLayerVisible: false,
  zlxmLayerVisible: false,
  zlqyLayerVisible: false,
  jjjgLayerVisible: false,
  wgfwLayerVisible: true,
  data: {}
};

export const getStoreData = (target: string, xzqh: string) => {
  const data = store.data[target];
  if (!data) {
    store.data[target] = {};
    return null;
  }
  if (!data[xzqh]) {
    return null;
  }
  return data[xzqh] as any[];
};

export const setStoreData = (target: string, xzqh: string, data: any) => {
  if (!store.data[target]) {
    store.data[target] = {};
  }
  store.data[target][xzqh] = data;
};

export default store;
